<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <p id="upda">hhhh</p>
    <form action="">
        <label for="username">用户名</label>
        <input type="text" id="username" placeholder="请输入用户名">
        <br>
        <label for="pwd">密码</label>
        <input type="password" id="pwd" placeholder="请输入密码">
        <br>
        <button type="button" onclick="updatauserinfo()">提交</button>
    </form>
    <script>
        function updatauserinfo(){
            // alert('hhh');
            var userdoc = document.getElementById('pwd');
            alert(userdoc.value);
            
        }
    </script>
</body>
</html>
<!-- <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <p id="upda">hhhh</p>
    <form action="">
        <label for="username">用户名</label>
        <input type="text" id="username" placeholder="请输入用户名">
        <br>
        <label for="pwd">密码</label>
        <input type="password" id="pwd" placeholder="请输入密码">
        <br>
        <button type="button" onclick="updatauserinfo()">提交</button>
    </form>
    <script>
        function updatauserinfo(){
            // 添加调试信息
            console.log('函数已调用');
            var userdoc = document.getElementById('username');
            if (userdoc) {
                console.log('元素已获取');
                console.log(userdoc.value);
                alert(userdoc.value);
            } else {
                console.log('未找到元素');
            }
        }
    </script>
</body>
</html> -->